package cn.edu.lingnan.association.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.lingnan.association.dao.ClubDAO;
import cn.edu.lingnan.association.dao.UserDAO;
import cn.edu.lingnan.association.dto.Club;
import cn.edu.lingnan.association.dto.User;


public class InsertClubServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
			throws ServletException, IOException {
		
		 String cid = req.getParameter("cid");
		 
		 String cname = req.getParameter("cname");
		 byte cname2[] = cname.getBytes("ISO-8859-1");
			cname = new String(cname2,"GBK");
			
		 String cplace = req.getParameter("cplace");
		 byte cplace2[] = cplace.getBytes("ISO-8859-1");
		 cplace = new String(cplace2,"GBK");
		 
		 int cfree = Integer.parseInt(req.getParameter("cfree"));
		 
		 String teacher = req.getParameter("teacher");
		 byte teacher2[] = teacher.getBytes("ISO-8859-1");
		 teacher = new String(teacher2,"GBK");
		 
		 Club c = new Club();
		 ClubDAO cd = new ClubDAO();	 
		 c.setcId(cid);
		 c.setcName(cname);
		 c.setcPlace(cplace);		 
		 c.setcFree(cfree);
		 c.setTeacher(teacher);
		 int flag = cd.insertInfoToClub(c);	
		 if(flag == 1)
			 resp.sendRedirect(req.getContextPath()+"/admin/findallclub");
		 else
			 resp.sendRedirect(req.getContextPath()+"/error-404.html");
		
	}

	

}
